package com.ruoyi.erp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.erp.domain.ErpFixedFee;
import com.ruoyi.erp.service.IErpFixedFeeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 固定费用支出Controller
 * 
 * @author yanwenliang
 * @date 2024-12-30
 */
@RestController
@RequestMapping("/erp/FixedFee")
public class ErpFixedFeeController extends BaseController
{
    @Autowired
    private IErpFixedFeeService erpFixedFeeService;

    /**
     * 查询固定费用支出列表
     */
    @PreAuthorize("@ss.hasPermi('erp:FixedFee:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpFixedFee erpFixedFee)
    {
        startPage();
        List<ErpFixedFee> list = erpFixedFeeService.selectErpFixedFeeList(erpFixedFee);
        return getDataTable(list);
    }

    /**
     * 导出固定费用支出列表
     */
    @PreAuthorize("@ss.hasPermi('erp:FixedFee:export')")
    @Log(title = "固定费用支出", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpFixedFee erpFixedFee)
    {
        List<ErpFixedFee> list = erpFixedFeeService.selectErpFixedFeeList(erpFixedFee);
        ExcelUtil<ErpFixedFee> util = new ExcelUtil<ErpFixedFee>(ErpFixedFee.class);
        util.exportExcel(response, list, "固定费用支出数据");
    }

    /**
     * 获取固定费用支出详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:FixedFee:query')")
    @GetMapping(value = "/{fixedFeeId}")
    public AjaxResult getInfo(@PathVariable("fixedFeeId") String fixedFeeId)
    {
        return success(erpFixedFeeService.selectErpFixedFeeByFixedFeeId(fixedFeeId));
    }

    /**
     * 新增固定费用支出
     */
    @PreAuthorize("@ss.hasPermi('erp:FixedFee:add')")
    @Log(title = "固定费用支出", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpFixedFee erpFixedFee)
    {
        return toAjax(erpFixedFeeService.insertErpFixedFee(erpFixedFee));
    }

    /**
     * 修改固定费用支出
     */
    @PreAuthorize("@ss.hasPermi('erp:FixedFee:edit')")
    @Log(title = "固定费用支出", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpFixedFee erpFixedFee)
    {
        return toAjax(erpFixedFeeService.updateErpFixedFee(erpFixedFee));
    }

    /**
     * 删除固定费用支出
     */
    @PreAuthorize("@ss.hasPermi('erp:FixedFee:remove')")
    @Log(title = "固定费用支出", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fixedFeeIds}")
    public AjaxResult remove(@PathVariable String[] fixedFeeIds)
    {
        return toAjax(erpFixedFeeService.deleteErpFixedFeeByFixedFeeIds(fixedFeeIds));
    }
}
